home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -coverdisks- / 126a / football / user / cup_cupinformation.rexx < prev    next >
OS/2 REXX Batch file  |  1999-05-22  |  15KB  |  502 lines

  1. /* ***********************************************************************
  2.  
  3.    CUP INFORMATION PROGRAM FOR FOOTBALL REXX SUITE
  4.   -------------------------------------------------
  5.                    Copyright  Mark Naughton 1998
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       140998   First release.
  11.            160998   Changed way best record is calculated.
  12.  
  13. **************************************************************************
  14.  
  15. Procedure
  16. ---------
  17.  
  18. 1. Check files exist.
  19. 2. Read '.cf' file and get details. Read '.cfrw' and do the same.
  20. 3. If '.cfsave' doesn't exist, read the '.scf' file adjusting the output
  21.    for replays, extra time, first leg and penalties.
  22. 4. If '.cfsave' is found, read to display current matches.
  23. 5. Read '.scf' into an array. Search array, storing goals. When finished,
  24.    search through the team array, calculating the best record :
  25.  
  26.     (Goals Scored / Goals Away) * Matches Played
  27.  
  28.     Goals Scored = Goals Scored At Home + (Goals Scored Away * 1.5)
  29.  
  30. 6. Write data to a file and call an external sort program. Read the details
  31.    back in and delete the temporary file.
  32. 7. Adjust options.
  33. 8. Display report : display options/rounds, teams and the best record, the
  34.    current round matches and if the history file has been selected, read
  35.    the file for previous/current winners.
  36. 9. Exit.
  37.  
  38. ************************************************************************** */
  39. PARSE ARG league_stuff
  40.  
  41. version      = 1
  42. input_file   = '.cf'
  43. input2_file  = '.scf'
  44. input3_file  = '.cfrw'
  45. input4_file  = '.cfh'
  46. input5_file  = '.cfsave'
  47. output_file  = 'RAM:Football.tempcup'
  48. title        = '*CUP_TITLE='
  49. thirdpl      = '*CUP_THIRD='
  50. rounddef     = '*CUP_RNDDEF='
  51. currond      = '*CUP_ROND='
  52. currrondn    = '*CUP_CRDN='
  53. roundddef    = '*CUP_RDEF='
  54. cuphistory   = '*CUP_HISTORY='
  55. thirdpl      = '*CUP_THIRD='
  56. teams_cnt    = '*CUP_TCNT='
  57. awaygs       = '*CUP_AWAYG='
  58. schedtype    = '*CUP_SCHEDULE='
  59. first        = '*WINNER='
  60. pkversion    = '*  Version='
  61. matches.     = '???'
  62. separator    = '*'
  63. teams.       = '???'
  64. rnds.        = '???'
  65. lines.       = '???'
  66. replays.     = '???'
  67. working.     = '???'
  68. losing.      = '???'
  69. repct        = 0
  70. repno.       = '???'
  71. tcount       = 0
  72. ttc          = 0
  73. rndcnt       = 0
  74. linesct      = 0
  75. league_file  = "Data/"league_stuff
  76. curnd        = ''
  77. curndn       = 0
  78. not_played   = "__   __"
  79. mcount       = 0
  80. bstats.      = '???'
  81. btemp.       = '???'
  82. btcnt        = 0
  83. bpstats.     = '???'
  84. bgsstats.    = '???'
  85. bgastats.    = '???'
  86. bagstats.    = '???'
  87.  
  88.  
  89. parse var league_stuff league_file search_team
  90. league_file = "Data/" || league_file
  91.  
  92. if exists(league_file || input_file) = 0  then exit
  93. if exists(league_file || input2_file) = 0 then exit
  94.  
  95. tcount = 0
  96. if open(datafile,league_file || input_file,'r') then do
  97.    do while ~eof(datafile)
  98.       line = readln(datafile)
  99.       if pos(title,line) > 0 then        cupname  = delstr(line,1,11)
  100.       if pos(thirdpl,line) > 0 then      third    = delstr(line,1,11)
  101.       if pos(awaygs,line) > 0 then       awaygoals= delstr(line,1,11)
  102.       if pos(pkversion,line) > 0 then    fversion = delstr(line,1,12)
  103.       if pos(cuphistory,line) > 0 then   cuph     = delstr(line,1,13)
  104.       if pos(schedtype,line) > 0 then    scht     = delstr(line,1,14)
  105.       if pos(rounddef,line) > 0 then do
  106.          rndcnt = rndcnt + 1
  107.          rnds.rndcnt = delstr(line,1,12)
  108.       end
  109.       if pos(separator,line) = 0 then do
  110.          line = strip(line)
  111.          tcount       = tcount + 1
  112.          teams.tcount = line
  113.       end
  114.    end
  115.    close(datafile)
  116. end
  117. else do
  118.    say
  119.    say "ERROR :    (CupInformation)"
  120.    say
  121.    say "Unable to open '"league_file || input_file"' file."
  122.    exit
  123. end
  124.  
  125. if open(datafile,league_file || input3_file,'r') then do
  126.    do while ~eof(datafile)
  127.       line = readln(datafile)
  128.       if pos(currond,line)   > 0 then crond  = strip(substr(line,11,2))
  129.       if pos(roundddef,line) > 0 then tcrondn= strip(substr(line,11,5))
  130.       if pos(currrondn,line) > 0 then do
  131.          crondn = strip(substr(line,11,30))
  132.          tleg_no = 0
  133.          if pos("1 Leg",line) > 0 then tleg_no = 1
  134.          if pos("2 Legs",line) > 0 then tleg_no = 2
  135.       end
  136.    end
  137.    close(datafile)
  138. end
  139. else do
  140.    say
  141.    say "ERROR :    (CupInformation)"
  142.    say
  143.    say "Unable to open '"league_file || input3_file"' file."
  144.    exit
  145. end
  146.  
  147. a      = 0
  148. mcount = 0
  149. if exists(league_file || input5_file) = 0 then do
  150.    if open(datafile,league_file || input2_file,'r') then do
  151.       do while ~eof(datafile)
  152.          line = readln(datafile)
  153.          if pos("*Round="strip(tcrondn),line) > 0 then
  154.             a = 1
  155.          if a = 1 then do
  156.             if pos(separator,line) = 0 & pos('#',line) = 0 then do
  157.                mcount = mcount + 1
  158.                matches.mcount = line
  159.             end
  160.             else do
  161.                if pos("Replay",line) > 0 then do
  162.                   mcount = mcount + 1
  163.                   matches.mcount = " "
  164.                   mcount = mcount + 1
  165.                   matches.mcount = "Replay"
  166.                   mcount = mcount + 1
  167.                   matches.mcount = "------"
  168.                   mcount = mcount + 1
  169.                   matches.mcount = " "
  170.                end
  171.                if pos("#1st Leg",line) > 0 then do
  172.                   mcount = mcount + 1
  173.                   matches.mcount = overlay("After 1st Leg",line,1,13)
  174.                end
  175.                if pos("#Score After Extra Time",line) > 0 then do
  176.                   mcount = mcount + 1
  177.                   matches.mcount = overlay("Score After Extra Time  ",line,1,23)
  178.                end
  179.                if pos("#Penalties",line) > 0 then do
  180.                   mcount = mcount + 1
  181.                   matches.mcount = overlay("After Penalties",line,1,15)
  182.                end
  183.             end
  184.          end
  185.       end
  186.       close(datafile)
  187.    end
  188.    else do
  189.       say
  190.       say "ERROR :    (CupInformation)"
  191.       say
  192.       say "Cannot open '"league_file||input2_file"' for reading."
  193.       exit
  194.    end
  195. end
  196. else do
  197.    if open(datafile,league_file || input5_file,'r') then do
  198.       do while ~eof(datafile)
  199.          line = readln(datafile)
  200.          if pos(separator,line) = 0 & pos('#',line) = 0 then do
  201.             mcount = mcount + 1
  202.             matches.mcount = line
  203.          end
  204.          else do
  205.             if pos(not_played,line) = 0 then do
  206.                if pos("Replay",line) > 0 then do
  207.                   mcount = mcount + 1
  208.                   matches.mcount = " "
  209.                   mcount = mcount + 1
  210.                   matches.mcount = "Replay"
  211.                   mcount = mcount + 1
  212.                   matches.mcount = "------"
  213.                   mcount = mcount + 1
  214.                   matches.mcount = " "
  215.                end
  216.                if pos("#1st Leg",line) > 0 then do
  217.                   mcount = mcount + 1
  218.                   matches.mcount = line
  219.                   matches.mcount = overlay("After 1st Leg",matches.mcount,1,13)
  220.                end
  221.                if pos("#Score After Extra Time",line) > 0 then do
  222.                   mcount = mcount + 1
  223.                   matches.mcount = line
  224.                   matches.mcount = overlay("Score After Extra Time ",matches.mcount,1,23)
  225.                end
  226.                if pos("#Penalties",line) > 0 then do
  227.                   mcount = mcount + 1
  228.                   matches.mcount = line
  229.                   matches.mcount = overlay("After Penalties",matches.mcount,1,15)
  230.                end
  231.             end
  232.          end
  233.       end
  234.       close(datafile)
  235.    end
  236.    else do
  237.       say
  238.       say "ERROR :    (CupInformation)"
  239.       say
  240.       say "Cannot open '"league_file||input5_file"' for reading."
  241.       exit
  242.    end
  243. end
  244.  
  245. do i=1 to tcount
  246.    bpstats.i = 0
  247.    bgsstats.i = 0
  248.    bgastats.i = 0
  249.    bagstats.i = 0
  250. end
  251. np    = 0
  252. btcnt = 0
  253. if open(datafile,league_file || input2_file,'r') then do
  254.    do while ~eof(datafile)
  255.       line = readln(datafile)
  256.       btcnt = btcnt + 1
  257.       btemp.btcnt = line
  258.    end
  259.    close(datafile)
  260. end
  261. else do
  262.    say
  263.    say "ERROR :    (CupInformation)"
  264.    say
  265.    say "Cannot open '"league_file||input2_file"' for reading."
  266.    exit
  267. end
  268. do k=1 to btcnt
  269.    if pos(not_played,btemp.k) = 0 & pos(separator,btemp.k)